package com.cssw.fyzb.busi.api.user;

import com.cssw.fyzb.busi.service.user.UserRelService;
import com.cssw.fyzb.busi.service.user.UserService;
import com.cssw.fyzb.core.model.dodb.User;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.Function;
import com.ydn.appserver.annotations.Parameter;
import com.ydn.appserver.annotations.Type;
import com.ydn.dbframe.kit.StrKit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import static com.cssw.fyzb.busi.util.Bizs.*;

/**
 * 新增用户
 *
 * @author Feng Chen
 */
@Function(description = "获取用户关注数量", parameters = {
        @Parameter(name = "userId", type = Type.String, description = "用户标识", required = true)
})
@Component
public class GetFollowNum implements Action {

    @Autowired
    private UserRelService userRelService;

    private static final Logger logger = LoggerFactory.getLogger(LoginByPwd.class);

    @Override
    public Response execute(Request request) throws Exception {
        Long userId = request.getLong("userId");
        try {
            Integer num = userRelService.getFollowNum(userId);
            return Response.success("").put("num", num);
        } catch (Exception e) {
            logger.error("", e);
            return Response.fail("获取用户关注数量失败");
        }
    }

}
